<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script language="javascript" type="text/javascript" src="js/jquery-1.8.3.js"></script>
<script language="javascript" type="text/javascript" src="js/common.js"></script>
<title>DailyWork View</title>
<script language="JavaScript" src="<%=basePath %>js/jquery-calendar.js"></script>
<link href="css/jquery-calendar.css" rel="stylesheet" type="text/css" />
<script language="javascript" type="text/javascript">
//<![CDATA[
$(document).ready(function (){
	$("#date,#selectDate").calendar({
		//初始化
		dateFormat: 'YMD/',     //日期格式
		timeSeparators:''       //时分设置
	});
});
//]]>
	function search() {
		var date1 = $("#date").val();
		document.forms["wrinfo"].action = "searchWrinfoOfDailyWork";
		document.forms["wrinfo"].submit();
	}
	function searchDaily(){
		 var para = $("#ajaxForm").serialize();
		  $.ajax({    
		     url:'findDaily_DailyWorkAction.action',   
		     data:para,
		     type:'post',   
		     dataType:'html', 
		     cache:false,       
		     success: function(data){
			  data.replace(/th>\s+<th>/g,"th><th");
			  data.replace(/td>\s+<td>/g,"td><td");
			      $("#dailyResult").html(data);
			      alert(data);  
                 alert($("#dailyResult").html());
			      //sum();
		  	}, 
		     error:update_c1
		  });  
	}
	function update_c1(data){
		alert("error");
	}  
	function rewrite() {
		document.forms["wrinfo"].action = "rewrite";
		document.forms["wrinfo"].submit();
	}
    function sum(){
    	var costObj=document.getElementsByName("cost");
    	var expHrsObj=document.getElementsByName("expHrs");
    	   if(costObj!=null)
    	   {
    	    costCount=costObj.length;
    	    var sum=0;
	    	    if(costCount!=null)
	    	    {
		    	     for(var j=0;j<costCount;j++)
		    	     {
		    	    	 sum+=Number(costObj[j].value);
		    	      }
	    	    }
    	   }

    	   if(expHrsObj!=null)
    	   {
	    		expHrsCount=expHrsObj.length;
	    	    var sumExpHrs=0;
	    	    if(expHrsCount!=null)
	    	    {
		    	     for(var j=0;j<expHrsCount;j++)
		    	     {
		    	    	 sumExpHrs+=Number(expHrsObj[j].value);
		    	      }
	    	    }
	            $("#tab").append("<tr align='center'>"
	                    +"<td></td>"
	                    +"<td></td>"
	                    +"<td></td>"
	                   +"<td>合计</td>"
	                   +"<td class="+"tdNumber"+">"+sumExpHrs+"</td>"
	                   +"<td class="+"tdNumber"+">"+sum+"</td>"
	                   +"<td></td>"
	                   +"<td></td>"
	                   +"<td></td>"
	                +"</tr>");            
    	   }
    }
	function editDial() {

		$(document).ready(function(){
			if($(":checkbox").is(":checked")) {
				
				var r = confirm("确定更新么？");
				if (r) {
					document.forms["wrinfo"].action = "update";
					document.forms["wrinfo"].submit();
				}
			} 
			else {
				alert("No data selected.");
			}
			});
	}; 
	function deleteAll(){
		$(document).ready(function(){
				if($(":checkbox").is(":checked")) {
					var r = confirm("确定删除么？");
					if (r) {
						document.forms["wrinfo"].action = "delateDailyInfo";
						document.forms["wrinfo"].submit();
					}
				} 
				else {
					alert("No data selected.");
				}
				});
		}; 
	function showadd() {
		document.forms["wrinfo"].action = "turn_addDaily";
		document.forms["wrinfo"].submit();
	}

	function checkAllInfo(){
		var click = document.getElementById("doSelect").checked;
		if(click == true){
			$(":checkbox").attr("checked", true);
			}
		else{
			$(":checkbox").attr("checked", false);
			}

		}
</script>
</head>
<body onload="sum()">
<%@ include file="topmenu.jsp"%>

<CENTER>
<div id="container">
<s:form theme="simple" method="post"name="wrinfo" onsubmit="return false" id="ajaxForm">

	<div id="content">
	<div id="top" align="left">
	<table class="table">
		<tr>
			<td><s:text name ="COMMON_LABEL_RESPONSIBLEUSER"/>&nbsp;
			<s:select
				list="dailyWorkBean.selectListBean.allUserName" name="dailyWorkBean.daily.userId" 
				listKey="key" listValue="name" headerValue="All" headerKey="0"
				cssStyle="width: 76px;">
			</s:select>
			<s:text name ="CMS00003_LABEL_TEAM"/>&nbsp;
			<s:select
				list="dailyWorkBean.selectListBean.teamName" name="dailyWorkBean.daily.teamKey" 
				listKey="key" listValue="name" headerValue="All" headerKey="0"
				cssStyle="width: 90px;">
			</s:select>
			<s:text name ="CMS00001_LABEL_CHOOSEDATE"/>:&nbsp;&nbsp;&nbsp;&nbsp;<s:textfield name="dailyWorkBean.daily.repDate" id="date"
			    cssStyle="width: 70px;" />&nbsp;
			 <s:submit value = "%{getText('COMMON_BUTTON_SEARCH')}" onclick="search();" cssClass="ButtonCss"/>
		</tr>
	</table>
	<table class="table">
		
	</table>
	<table class="table">
		<tr>
			<th><s:text name ="COMMON_LABEL_NUMBER"/></th>
			<th><s:text name ="CMS00001_LABEL_CASENAME"/></th>
			<th><s:text name ="COMMON_LABEL_RESPONSIBLEUSER"/></th>
			<th><s:text name ="CMS00001_LABEL_ESTIMATESTARTDATE"/></th>
			<th><s:text name ="CMS00001_LABEL_ESTIMATEENDDATE"/></th>
			<th><s:property value="%{getText('COMMON_LABEL_WRESTIMATCOST')}" escape="false"/></th>
			<th><s:text name ="CMS00001_LABEL_ACTUALSTARTDATE"/></th>
			<th><s:text name ="CMS00001_LABEL_ACTUALENDDATE"/></th>
			<th><s:property value="%{getText('CMS00001_LABEL_ACTUALCOST')}" escape="false"/></th>
			<th><s:property value="%{getText('CMS00001_LABEL_ETC')}" escape="false"/></th>
			<th><s:text name ="COMMON_LABEL_PRIORITY"/></th>
			<th><s:text name ="CMS00001_LABEL_STATUS"/></th>
		</tr>
		<c:if test="${not empty dailyWorkBean.dwrinfo}">
			<c:forEach items="${dailyWorkBean.dwrinfo}" var="dw">
				<tr>
					<td class="tdString">${dw.basewrNo}</td>
					<td class="tdString">${dw.wrName}</td>
					<td class="tdString">${dw.inChargeCdcKey}</td>
					<td class="tdString">${dw.smStartDate}</td>
					<td class="tdString">${dw.dueDate}</td>
					<td class="tdNumber">${dw.estimatedHour}</td>
					<td class="tdString">${dw.sdate}</td>
					<td class="tdString">${dw.modifyEndDate}</td>
					<td class="tdNumber">${dw.actualHour}</td>
					<td class="tdNumber">${dw.etc}</td>
					<td class="tdString">${dw.priority}</td>
					<td class="tdString">${dw.status}</td>
				</tr>
			</c:forEach>
		</c:if>
	</table>
	<hr />
	</div>
	<div id="bottom" align="left">
	<table border="0px" class="table" style="padding-left: 30px;">
		<tr>
			<c:if test="${id!=1}">
			<td align="right">
			<s:text name ="CMS00001_LABEL_CHOOSEDATE"/>:&nbsp;&nbsp;&nbsp;&nbsp;<s:textfield name="dailyWorkBean.daily.selectDate" id="selectDate"
			    cssStyle="width: 70px;" />&nbsp;
			<input type="button" value="检索" onclick="searchDaily();" class="ButtonCss"/>
			<s:submit value="复写" onclick="rewrite()" cssClass="ButtonCss"></s:submit>
			<s:submit value="%{getText('CMS00001_BUTTON_ADD')}" onclick="showadd();" cssClass="ButtonCss"></s:submit>
			<s:submit value="%{getText('CMS00001_BUTTON_UPDATE')}" onclick="editDial();" cssClass="ButtonCss"></s:submit>
			<s:submit value="%{getText('CMS00001_BUTTON_DELETE')}" onclick="deleteAll();" cssClass="ButtonCss"></s:submit>
			</td></c:if>
		</tr>
	</table>

		<div id="dailyResult">
			<s:include value="includeDailyResult.jsp"></s:include>
		</div>
	</div>
</s:form>
<div id="footer">Copyright accenture.com.cn</div>
</div>
</CENTER>
</body>
</html>